/*
 * @Description: 
 * @version: 
 * @Author: cy
 * @Date: 2021-12-23 09:50:22
 * @LastEditors: cy
 * @LastEditTime: 2021-12-23 10:09:09
 */
// 题目：leetCode-237:请编写一个函数，使其可以删除某个链表中给定的（非末尾）节点，你将
// 只被给定要求被删除的节点,如果head=[4,5,1,9],要删除5，那么head=[4,1,9]
const a = { val: '4' };
const b = { val: '5' };
const c = { val: '1' };
const d = { val: '9' };
a.next = b;
b.next = c;
c.next = d;
var deleteNode = function(node) {
    node.val = node.next.val;
    node.next = node.next.next;
}
print(a);
console.log('-------------链表删除c节点----------------------')
deleteNode(c);
print(a);
function print(a) {
    let p = a
    while(p) {
        console.log(p.val);
        p = p.next;
    }
}